package site.fantasycube.demo.service;

import org.apache.http.Header;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.stereotype.Component;
import site.fantasycube.demo.util.HttpUtil;

import java.util.ArrayList;
import java.util.List;

@Component
public class TestDemo {

    //http请求测试
    public void testHttp(){
        List<Header> headerList = new ArrayList<>();
        headerList.add(new BasicHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"));
        headerList.add(new BasicHeader("referer","www.baidu.com"));
        List<NameValuePair> nameValuePairList = new ArrayList<>();
        nameValuePairList.add(new BasicNameValuePair("wd", "gitee"));
        String http = HttpUtil.getHttp("https://www.baidu.com/s", nameValuePairList, headerList);
        System.out.println("请求结果为："+http);
    }
}
